package cn.tedu.springboot.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

public class TestDelete {
    private static Connection conn =null;
    private static PreparedStatement ps =null;
    public static void main(String[] args) throws Exception{
        Class.forName("com.mysql.jdbc.Driver");
        String url ="jdbc:mysql://localhost:3306/tedu?useUnicode=true&characterEncoding=utf8";
        String user = "root";
        String psd  ="root";
        conn = DriverManager.getConnection(url,user,psd);
        System.out.println("链接成功");
        String sql ="DELETE FROM location WHERE id =5";
        ps =conn.prepareStatement(sql);
        int rows = ps.executeUpdate();
        System.out.println(rows>0?"添加"+rows+"条记录成功！":"添加失败");
        ps.close();
    }
}
